<ul id='reservation-ul'>
	<!-- loop reservations -->
		<li class='reservation-li' id="reservation_{{reservations' value.@chr_id}}">
		<span class='reservation-li-row'>	Date début : 	<span class='datedeb'>{{reservations' value.@chr_datedeb}}</span> 	</span>
		<span class='reservation-li-row'>	Date fin : 		<span class='datefin'>{{reservations' value.@chr_datefin}}</span> 	</span>
		<span class='reservation-li-row'> 	Locataire : 	<span class='commentaire'>{{reservations' value.@chr_loca}} {{reservations' value.@chr_firstname}}</span> 		</span>
		<span class="reservation-delete"><img src="{{baseurl}}global/img/globalbo/appartements/delete-128.png" style="vertical-align: middle; margin-left: 5px;"></span>
		<input type="hidden" name="prenom" class="prenom" value="{{reservations' value.@chr_firstname}}">
		<input type="hidden" name="daten" class="daten" value="{{reservations' value.@chr_daten}}">
		<input type="hidden" name="lieun" class="lieun" value="{{reservations' value.@chr_lieun}}">
		<input type="hidden" name="dateentree" class="dateentree" value="{{reservations' value.@chr_entree}}">
		<input type="hidden" name="adresse" class="adresse" value="{{reservations' value.@chr_addr}}">
		<input type="hidden" name="dept" class="dept" value="{{reservations' value.@chr_dept}}">
		<input type="hidden" name="ville" class="ville" value="{{reservations' value.@chr_ville}}">
		</li>
	<!-- endloop -->
</ul>

<script type="text/javascript">
/** Show reservation detail **/

var delet = false;
$(".reservation-delete").click(function(){
	if(!confirm("Êtes-vous sûr de vouloir supprimer la réservation ?"))
		return;
	var li = $(this).parent("li");
	var id = li.attr('id').replace('reservation_', '');
	li.fadeOut("slow");
	emptyReservation();
	$('#component-change-reservation-form-indicator').val("new");
	url="{{baseurl}}admin/frbFlat/frbFlat_MainController/appartements";
	$.ajax({
		urlApp: url,
		type: 'POST',
		cache: false,
		data: "del_reservation=true&reservation_id="+id,
		success: function(html){
			//alert(html);
		}
	});	
	delet = true;
	//alert(id);
});

$('.reservation-li').click(function(){
	if(delet){
		delet = false;
		return;
	}
	emptyReservation();
	var datedeb = $(this).children('.reservation-li-row:eq(0)').children('.datedeb').html();
	var datefin = $(this).children('.reservation-li-row:eq(1)').children('.datefin').html();
	if(datefin == "00/00/0000"){
		datefin="";
	}
	var commentaire = $(this).children('.reservation-li-row:eq(2)').children('.commentaire').html();
	var id = $(this).attr('id').replace('reservation_', '');
	var prenom = $(this).children(".prenom").val();
	var daten = $(this).children(".daten").val();
	var lieun = $(this).children(".lieun").val();
	var dateentree = $(this).children(".dateentree").val();
	var dept = $(this).children(".dept").val();
	var adresse = $(this).children(".adresse").val();
	var ville = $(this).children(".ville").val();

	$('#component-change-reservation-form-datedeb').val(datedeb);
	$('#component-change-reservation-form-datefin').val(datefin);
	$('#component-change-reservation-form-locataire').val(commentaire);
	$('#component-change-reservation-form-chambreres').val(id);
	$('#component-change-reservation-form-prenom').val(prenom);
	$('#component-change-reservation-form-daten').val(daten);
	$('#component-change-reservation-form-lieun').val(lieun);
	$('#component-change-reservation-form-date_entree').val(dateentree);
	$('#component-change-reservation-form-dept').val(dept);
	$('#component-change-reservation-form-adresse').val(adresse);
	$('#component-change-reservation-form-ville').val(ville);
	$('#component-change-reservation-form-indicator').val("change");
});

</script>